//
//  UIAlertController+Closure.swift
//  BLE-Peripheral
//
//  Created by wujia121 on 2018/2/10.
//  Copyright © 2018年 steven. All rights reserved.
//

import UIKit

extension UIAlertController {

    class public func showAlertController(style:UIAlertControllerStyle, title: String?, message: String?, okActionTitle:String?, okAction:((UIAlertAction) -> Swift.Void)?, cancelActionTitle:String?, cancelAction:((UIAlertAction) -> Swift.Void)?) -> Void {
        
        let alertVC = UIAlertController(title: title, message: message, preferredStyle:style)
        
        if okActionTitle != nil {
            let okAction = UIAlertAction(title: okActionTitle, style: .default, handler:okAction )
            alertVC.addAction(okAction)
        }
        
        if cancelActionTitle != nil {
            let cancelAction = UIAlertAction(title: cancelActionTitle, style: .cancel, handler: cancelAction)
            alertVC.addAction(cancelAction)
        }
        
        RootVC?.present(alertVC, animated: true, completion: nil)
    }
    
}
